/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package explorer;

import java.io.File;
import java.util.Date;

/**
 *
 * @author Carmen
 */
public class FileModel {
    
    private String _path = "";
    private String _name = "";
    private boolean _readable = false;
    private boolean _writable = false;
    private boolean _hidden = false;
    private boolean _directory = false;
    private boolean _file = false;
    private String _parent = "";
    private long _size = 0;
    private Date _lastModified = null;
    
    public FileModel() {
        
    }
    
    public FileModel(File file) {
        _path = file.getAbsolutePath();
        _name = file.getName();
        _readable = file.canRead();
        _writable = file.canWrite();
        _hidden = file.isHidden() || file.getName().startsWith(".");
        _directory = file.isDirectory();
        _file = file.isFile();
        _parent = file.getParent();
        _size = file.length();
        _lastModified = new Date(file.lastModified());
    }

    /**
     * @return the _path
     */
    public String getPath() {
        return _path;
    }

    /**
     * @param path the _path to set
     */
    public void setPath(String path) {
        this._path = path;
    }
    
//    public Icon getIcon() {
//        
//    }

    /**
     * @return the _name
     */
    public String getName() {
        return _name;
    }

    /**
     * @param name the _name to set
     */
    public void setName(String name) {
        this._name = name;
    }

    /**
     * @return the _readable
     */
    public boolean isReadable() {
        return _readable;
    }

    /**
     * @param readable the _readable to set
     */
    public void setReadable(boolean readable) {
        this._readable = readable;
    }

    /**
     * @return the _writable
     */
    public boolean isWritable() {
        return _writable;
    }

    /**
     * @param writable the _writable to set
     */
    public void setWritable(boolean writable) {
        this._writable = writable;
    }

    /**
     * @return the _parent
     */
    public String getParent() {
        return _parent;
    }

    /**
     * @param parent the _parent to set
     */
    public void setParent(String parent) {
        this._parent = parent;
    }

    /**
     * @return the _size
     */
    public long getSize() {
        return _size;
    }

    /**
     * @param size the _size to set
     */
    public void setSize(long size) {
        this._size = size;
    }

    /**
     * @return the _lastModified
     */
    public Date getLastModified() {
        return _lastModified;
    }

    /**
     * @param lastModified the _lastModified to set
     */
    public void setLastModified(Date lastModified) {
        this._lastModified = lastModified;
    }
    
    @Override
    public String toString() {
        return this._name;
    }

    /**
     * @return the _hidden
     */
    public boolean isHidden() {
        return _hidden;
    }

    /**
     * @param hidden the _hidden to set
     */
    public void setHidden(boolean hidden) {
        this._hidden = hidden;
    }

    /**
     * @return the _directory
     */
    public boolean isDirectory() {
        return _directory;
    }

    /**
     * @param directory the _directory to set
     */
    public void setDirectory(boolean directory) {
        this._directory = directory;
    }

    /**
     * @return the _file
     */
    public boolean isFile() {
        return _file;
    }

    /**
     * @param file the _file to set
     */
    public void setFile(boolean file) {
        this._file = file;
    }
}
